﻿using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Web.Mvc;

namespace Back_end.Models
{
    public class Complaint
	{
		/// <summary>
		/// 举报Id，格式为10位的DateTime + UserId
		/// 如1504100927123表示15年4月10日9点27分Id为123的用户发布
		/// </summary>
		[Key]
		[HiddenInput(DisplayValue = false)]
		public string ComplaintId
		{ get; set; }

		/// <summary>
		/// ApplicationUser的UserName
		/// 不用Id，方便显示
		/// </summary>
		[Required]
		[Display(Name = "发布者用户名")]
		public string UserName
		{ get; set; }

		[DataType(DataType.Date)]
		[Display(Name = "发布日期")]
		[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}")]
		public DateTime PublishedDate 
		{ get; set; }

		[Display(Name = "文字描述")]
		public string Text
		{ get; set; }

		/// <summary>
		/// 照片路径，所有照片路径存一起，使用'|'分隔
		/// 最多不要过9张
		/// </summary>
		[Required]
		[Display(Name = "照片")]
		public string PicturePath
		{ get; set; }

		[Required]
		[Display(Name = "地点")]
		public string Location
		{ get; set; }

		[Required]
		[Display(Name = "坐标")]
		[HiddenInput(DisplayValue = false)]
		public string Coordinate
		{ get; set; }

		/// <summary>
		/// 标签，也使用'|'分隔
		/// 前端限制五个，以及每个的长度
		/// </summary>
		[Display(Name = "标签")]
		public string Tag
		{ get; set; }

		[Display(Name = "污染来源企业")]
		public string Company
		{ get; set; }

		/// <summary>
		/// false为不通过，null为未处理，true为通过
		/// </summary>
		[Display(Name = "审核状态")]
		public bool? AllowedPublished
		{ get; set; }

		/// <summary>
		/// false为处理中，null为未处理，true为处理结束
		/// </summary>
		[Display(Name = "处理状态")]
		public bool? HadProcessed
		{ get; set; }

		[Display(Name = "处理结果")]
		public string Review
		{ get; set; }

		/// <summary>
		/// 关注者用户名
		/// </summary>
		//[Display(Name = "关注者")]
		//public virtual List<string> FollowedUsers
		//{ get; set; }

		//public virtual List<string> Likes
		//{ get; set; }

		/// <summary>
		/// 权重，权重高的排在前
		/// </summary>
		[HiddenInput(DisplayValue = false)]
		public double Weight
		{ get; set; }
	}

	public class FollowedUser
	{
		[Key, Column(Order = 1)]
		public string ComplaintId
		{ get; set; }

		[Key, Column(Order = 2)]
		public string UserName
		{ get; set; }
	}

	public class LikedUser
	{
		[Key, Column(Order = 1)]
		public string ComplaintId
		{ get; set; }

		[Key, Column(Order = 2)]
		public string UserName
		{ get; set; }
	}
}